<script src="http://localhost/php/login/js/jquery.js">
</script>
<script>
$(document).ready(function(){
  $(".addclientname").keyup(function()
  {
  
   var va = $(".addclientname").val();
  $.ajax(
  {
  url:"auto.php?value="+va,
   success:function(result)
   {
   //alert('asdads');
   $(".option").show();
   $(".option").html(result);
   $(".option").each(function()
   {
   $(".option ul li").click(function()
   {
   var optionvalue = $(this).html();
   $(".addclientname").val(optionvalue);
   
   var opt = $(this).attr('id');
   $(".clientname").val(opt);
   
   
   });
   
   });
   
   },
   error:function()
   {
   $(".option").html(result);
   }
   });
  });
});
</script>







<?php
$connect = mysql_connect('localhost','root','');
mysql_select_db("admintool");
error_reporting(E_ALL ^ E_NOTICE);
session_start();
?>
<?php
if($_SESSION["loggedin"]==true && $_SESSION["role"]==admin)
{
if(isset($_SESSION[msg]))
{
echo $_SESSION[msg];
unset($_SESSION[msg]);
}
?>
<?php
$id = $_GET['id'];

$edit = "SELECT * from project WHERE projectid='$id'";
$editresult = mysql_query($edit);
$editvalue = mysql_fetch_array($editresult);
//print_r($editvalue);

$editclient  = "SELECT * from userclient WHERE projectid='$id'";
$editclientresult = mysql_query($editclient);
$ec = mysql_fetch_array($editclientresult);
//print_r($ec);

$ecname = "SELECT * from client WHERE clientid='$ec[clientid]'";
$ecq = mysql_query($ecname);
$ea = mysql_fetch_array($ecq);
//print_r($ea);


?>
<form action="edit.php" method="post">
<input type="hidden" value="<?php echo "$editvalue[projectid]";?> " name="id" />

<label>Project Name</label>
<input type="text" value="<?php echo "$editvalue[projectname]";?>" name="addprojectname" /><br><br>

<label>Client Name</label>
<input type="text" value="<?php echo "$ea[clientname]";?>" name="addclientname" class="addclientname" /><br><br>

<input type="text" value="<?php echo "$ec[clientid]";?>" style="display:none;" name="clientname" class="clientname"/>
<div class="option" style="display:none;border: 1px solid;
    bottom: 20px;
    height: 39px;
    left: 82px;
    margin-right: 103px;
    overflow-x: auto;
    overflow-y: scroll;
    position: relative;
    width: 143px;"></div>


<label>Project Value</label>
<input type="text" value="<?php echo "$editvalue[projectvalue]";?>" name="addprojectvalue" /><br><br>
<label>Project Type</label>
<input type="radio" name="addprojecttype" value="offshore" <?php if($editvalue[projecttype] == "offshore"){echo 'checked="checked"';}?> />offshore<br>
<input type="radio" name="addprojecttype" value="onshore" <?php if($editvalue[projecttype] == "onshore"){echo 'checked="checked"';}?>/>onshore<br><br>
<!--<input type="text" value="<?php echo "$editvalue[projecttype]";?>" name="addprojecttype" /><br><br>-->
<label>Project Domain</label>
<input type="text" value="<?php echo "$editvalue[projectdomain]";?>" name="addprojectdomain" /><br><br>



<input type="submit" value="Edit" name="editform" />
</form>
<?php
if(isset($_POST['editform']))
{
$id = $_POST['id'];


print_r($id);
$update = "UPDATE project SET projectname='$addprojectname',
projectvalue='$addprojectvalue',projecttype='$addprojecttype',projectdomain='$addprojectdomain' WHERE projectid='$id'";
$updatevalue = mysql_query($update);

$updateclient = "UPDATE userclient SET clientid='$clientname'";
$uc = mysql_query($updateclient);

//print_r($uc);

header("Location: project_list.php");
}
}
else
{
header("Location: login.php");
}
?>

